home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-04-03 | 6.3 KB | 231 lines | [TEXT/MPS ] |
- //----------------------------------------------------------------------------------------
- // Nothing.cp
- // Copyright © 1986-96 by Apple Computer, Inc. All rights reserved.
- //----------------------------------------------------------------------------------------
-
- /*
- This is a very small sample application. The application's windows each contain
- the word 'MacApp', in large type, and are framed by a large gray border.
-
- All applications that create views procedurally need to reimplement at least
- three methods:
-
- TApplication::DoMakeDocument Launches the appropriate type of Document object
- TDocument::DoMakeViews Launches the appropriate type of View and window
- objects
- TView::Draw Draws the contents of a view
-
- This application, however, consists of the reimplementation of only one method,
- TView::Draw. This is possible since the view is created from templates; MacApp
- supplies the default 'view' resource. So in a sense this application is the smallest
- possible MacApp application.
- */
-
- // MacApp
-
- #ifndef __MACAPPTYPES__
- #include "MacAppTypes.h"
- #endif
-
- #ifndef __UAPPLICATION__
- #include "UApplication.h"
- #endif
-
- #ifndef __UDOCUMENT__
- #include "UDocument.h"
- #endif
-
- #ifndef __UERRORMGR__
- #include "UErrorMgr.h"
- #endif
-
- #ifndef __UMACAPPGLOBALS
- #include "UMacAppGlobals.h"
- #endif
-
- #ifndef __UMACAPPUTILITIES__
- #include "UMacAppUtilities.h"
- #endif
-
- #ifndef __UVIEW__
- #include "UView.h"
- #endif
-
- // Toolbox
-
- #ifndef __FONTS__
- #include <Fonts.h>
- #endif
-
- #ifndef __QUICKDRAW__
- #include <Quickdraw.h>
- #endif
-
- #ifndef __TYPES__
- #include <Types.h>
- #endif
-
- //----------------------------------------------------------------------------------------
- // Constants
- //----------------------------------------------------------------------------------------
-
- const OSType kSignature = 'SS00'; // Application signature
- const OSType kFileType = 'SF00'; // File-type code used for document files
- // created by this application
-
-
- //----------------------------------------------------------------------------------------
- // TNothingApplication:
- //----------------------------------------------------------------------------------------
-
- class TNothingApplication : public TApplication
- {
- MA_DECLARE_CLASS;
-
- public:
- virtual ~TNothingApplication();
-
- void INothingApplication();
-
- virtual TDocument* DoMakeDocument(CommandNumber itsCommandNumber, TFile* itsFile);
- // Override
- };
-
-
- //----------------------------------------------------------------------------------------
- // TDefaultView:
- //----------------------------------------------------------------------------------------
-
- class TDefaultView : public TView
- {
- MA_DECLARE_CLASS;
-
- public:
- virtual ~TDefaultView();
-
- virtual void Draw(const VRect& area);
- // Draws the view seen in the window. Every nonblank view MUST override this
- // method.
- };
-
-
-
- //========================================================================================
- // CLASS TNothingApplication
- //========================================================================================
- #undef Inherited
- #define Inherited TApplication
-
- MA_DEFINE_CLASS_M1(TNothingApplication, TApplication);
-
- //----------------------------------------------------------------------------------------
- // TNothingApplication destructor
- //----------------------------------------------------------------------------------------
-
- TNothingApplication::~TNothingApplication()
- {
- }
-
- //----------------------------------------------------------------------------------------
- // TNothingApplication::INothingApplication:
- //----------------------------------------------------------------------------------------
-
- void TNothingApplication::INothingApplication()
- {
- IApplication(kFileType, kSignature);
-
- // So my view will be substituted when MacApp® creates the "default view"
-
- MA_REGISTER_SIGNATURE(TDefaultView, kStdDefaultView);
-
- // So we can create the view object by name
-
- MA_REGISTER_CLASS(TDefaultView)
- } // TNothingApplication::INothingApplication
-
- //----------------------------------------------------------------------------------------
- // TNothingApplication::DoMakeDocument:
- //----------------------------------------------------------------------------------------
-
- TDocument* TNothingApplication::DoMakeDocument(CommandNumber, TFile* /*itsFile*/)
- {
- TDocument* aDocument = new TDocument;
-
- aDocument->IDocument();
-
- return aDocument;
- } // TNothingApplication::DoMakeDocument
-
-
-
- //========================================================================================
- // CLASS TDefaultView
- //========================================================================================
- #undef Inherited
- #define Inherited TView
-
- MA_DEFINE_CLASS_M1(TDefaultView, TView);
-
- //----------------------------------------------------------------------------------------
- // TDefaultView destructor
- //----------------------------------------------------------------------------------------
-
- TDefaultView::~TDefaultView()
- {
- }
-
- //----------------------------------------------------------------------------------------
- // TDefaultView::Draw:
- //----------------------------------------------------------------------------------------
-
- void TDefaultView::Draw(const VRect&)
- {
- PenNormal();
- PenSize(10, 10);
- PenPat(&qd.dkGray);
-
- // Draw a dark gray frame
- FrameRect(&GetQDExtent());
-
- // Set font and size for subsequent display in the window
- TextFont(times); // a nice outline font
- TextSize(72);
-
- MoveTo(45, 90);
-
- // Draw the word 'MacApp®' in large type.
- DrawString("\pMacApp®");
-
- // Restore the pen state.
- PenNormal();
- } // TDefaultView::Draw
-
-
-
- //========================================================================================
- // GLOBAL Functions
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // main:
- //----------------------------------------------------------------------------------------
- #pragma push
- #pragma processor 68000
- #pragma segment Main
-
- void main()
- {
- InitUMacApp(3); // Initialize MacApp; 3 calls to MoreMasters
-
- TNothingApplication* aNothingApplication = new TNothingApplication;
- aNothingApplication->INothingApplication();
- aNothingApplication->Run();
- } // main
-
- #pragma pop
-
- //----------------------------------------------------------------------------------------
- // End of Nothing.cp
-
- #pragma segment Inline
-